<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/11/9 0009
  Time: 12:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/common/tagPage.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>修改密码</title>
    <meta name="keywords" content="中文"/>
    <meta name="description" content="下载"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <!-- basic styles -->

    <link href="${baseurl}statics/assets/css/bootstrap.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/font-awesome.min.css"/>

    <!--[if IE 7]>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/font-awesome-ie7.min.css"/>
    <![endif]-->

    <!-- page specific plugin styles -->

    <link rel="stylesheet" href="${baseurl}statics/assets/css/jquery-ui-1.10.3.custom.min.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/chosen.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/datepicker.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/bootstrap-timepicker.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/daterangepicker.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/colorpicker.css"/>

    <!-- fonts -->

    <link rel="stylesheet" href="${baseurl}statics/assets/css/fonts.css"/>

    <!-- ace styles -->

    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace.min.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-rtl.min.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-skins.min.css"/>

    <!--[if lte IE 8]>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-ie.min.css"/>
    <![endif]-->

    <!-- inline styles related to this page -->

    <!-- ace settings handler -->

    <script src="${baseurl}statics/assets/js/ace-extra.min.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

    <!--[if lt IE 9]>
    <script src="${baseurl}statics/assets/js/html5shiv.js"></script>
    <script src="${baseurl}statics/assets/js/respond.min.js"></script>
    <![endif]-->

    <script type="text/javascript">
        //Ajax提交表单
        function  button_onclick() {
            var k = window.confirm("确定是否要提交？");
            if (k) {
                if ($("#oldPassword").val() == null || $("#oldPassword").val() == "") {
                    alert("原密码不能为空");
                    return;
                }
                //验证是否选中角色
                if($("#form-field-2").val() == null || $("#form-field-2").val() == ""){
                    alert("新密码不能为空");
                    return;
                }
                if($("#form-field-3").val() == null || $("#form-field-3").val() == ""){
                    alert("确认密码不能为空");
                    return;
                }
                if($("#form-field-3").val() !=  $("#form-field-2").val()){
                    alert("两次密码不同!!");
                    return;
                }
                var userId = $("#userId").val();
                var newPassword = $("#form-field-2").val();
                alert(newPassword);
                $.ajax({
                    url: "${baseurl}sysUserController/updatePasswords",
                    type: "post",
                    data: {"id":userId,"userPassword":newPassword},
                    success: function (json) {
                        if(json.code=='0'){
                            alert("密码修改成功");
                            window.parent.location.href='${baseurl}loginjsp.do';
                        }
                    },
                    error: function () {
                        alert("密码修改失败");
                    }
                });
            }
        }
    </script>

</head>

<body>
<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try {
            ace.settings.check('breadcrumbs', 'fixed')
        } catch (e) {
        }
    </script>

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="#">系统管理</a>
        </li>

        <li>
            <a href="${baseurl}sysUserController/findPageAllSysUser">管理员列表</a>
        </li>
        <li class="active">修改密码</li>
    </ul><!-- .breadcrumb -->


</div>

<div class="page-content">
    <div class="page-header">
        <h1>
            修改密码
            <small>
                <i class="icon-double-angle-right"></i>
                请输入相关信息
            </small>
        </h1>
    </div><!-- /.page-header -->

    <div class="row">
        <div class="col-xs-12">
            <!-- PAGE CONTENT BEGINS -->

            <form class="form-horizontal" role="form" method="post">


                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" ><span style="color: red">*</span>原密码</label>

                    <div class="col-sm-9">
                        <input type="password" id="oldPassword" onblur="oldOK()" name="oldPassword" placeholder="请输入原密码"
                               class="col-xs-10 col-sm-5"/>
                        <input type="hidden" name="id" id="userId" value="${sysUser.id}"/>
                        <span id="oldMsg" style="margin-left: 10px;"></span>
                    </div>

                </div>
                <script type="text/javascript">
                  function  oldOK() {
                        //输入旧密码
                        var oldPassword = $("#oldPassword").val();
                        //提示信息
                        $.ajax({
                            type:'post',
                            contentType: "application/x-www-form-urlencoded; charset=utf-8",
                            url:'${webRoot}/sysUserController/oldPassword',
                            data:{"oldPassword":oldPassword},
                            success:function (data) {
                                if(data.code == "0"){
                                    $("#oldMsg").html("<span id='oldMsg' style='color: green;font-weight: bold;'>"+data.message+"</span>");
                                }else{
                                    $("#oldMsg").html("<span id='oldMsg' style='color: red;font-weight: bold;'>"+data.message+"</span>");
                                }
                            }
                        });
                  }
                </script>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2"><span style="color: red">*</span>新密码</label>

                    <div class="col-sm-9">
                        <input type="password" id="form-field-2" name="password" placeholder="请输入新密码"
                               class="col-xs-10 col-sm-5"/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-3"><span style="color: red">*</span>确认密码</label>

                    <div class="col-sm-9">
                        <input type="password" id="form-field-3" name="passwordOK" placeholder="请输入确认密码"
                               class="col-xs-10 col-sm-5"/>
                    </div>
                </div>


                <div class="clearfix form-actions">
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info" type="button" onclick="javascript:button_onclick();">
                            <i class="icon-ok bigger-110"></i>
                            提交
                        </button>

                        &nbsp; &nbsp; &nbsp;
                        <button class="btn btn-return" type="button">
                            <i class="icon-undo bigger-110"></i>
                            返回
                        </button>

                    </div>
                </div>
            </form>


        </div><!-- /.col -->
    </div><!-- /.row -->
</div><!-- /.page-content -->

<!-- basic scripts -->
<!--[if !IE]> -->

<script type="text/javascript">
    window.jQuery || document.write("<script src='${baseurl}statics/assets/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='${baseurl}statics/assets/js/jquery-1.10.2.min.js'>" + "<" + "/script>");
</script>
<![endif]-->

<script type="text/javascript">
    if ("ontouchend" in document) document.write("<script src='${baseurl}statics/assets/js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>
<script src="${baseurl}statics/assets/js/bootstrap.min.js"></script>
<script src="${baseurl}statics/assets/js/typeahead-bs2.min.js"></script>

<!-- page specific plugin scripts -->

<!--[if lte IE 8]>
<script src="${baseurl}statics/assets/js/excanvas.min.js"></script>
<![endif]-->

<script src="${baseurl}statics/assets/js/jquery-ui-1.10.3.custom.min.js"></script>
<script src="${baseurl}statics/assets/js/jquery.ui.touch-punch.min.js"></script>
<script src="${baseurl}statics/assets/js/chosen.jquery.min.js"></script>
<script src="${baseurl}statics/assets/js/fuelux/fuelux.spinner.min.js"></script>
<script src="${baseurl}statics/assets/js/date-time/bootstrap-datepicker.min.js"></script>
<script src="${baseurl}statics/assets/js/date-time/bootstrap-timepicker.min.js"></script>
<script src="${baseurl}statics/assets/js/date-time/moment.min.js"></script>
<script src="${baseurl}statics/assets/js/date-time/daterangepicker.min.js"></script>
<script src="${baseurl}statics/assets/js/bootstrap-colorpicker.min.js"></script>
<script src="${baseurl}statics/assets/js/jquery.knob.min.js"></script>
<script src="${baseurl}statics/assets/js/jquery.autosize.min.js"></script>
<script src="${baseurl}statics/assets/js/jquery.inputlimiter.1.3.1.min.js"></script>
<script src="${baseurl}statics/assets/js/jquery.maskedinput.min.js"></script>
<script src="${baseurl}statics/assets/js/bootstrap-tag.min.js"></script>

<!-- ace scripts -->

<script src="${baseurl}statics/assets/js/ace-elements.min.js"></script>
<script src="${baseurl}statics/assets/js/ace.min.js"></script>

<!-- inline scripts related to this page -->

<script type="text/javascript">
    $(".btn-return").click(function () {
        window.parent.location.href='${baseurl}firstIndex.do';
    });
</script>

</body>
</html>
